package managedBean;

import java.io.Serializable;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import javax.faces.event.PhaseEvent;

@ManagedBean(name="CustomerDisplayManagedBean")
@ViewScoped
public class CustomerDisplayManagedBean implements Serializable {

    private String name;
    private String address;
    private String mNumber;
    private String pNumber;
    private String age;
    private String emailAddress;
    private String jobPosition;
    private String maritalStatus;
    private String gender;
    private String customerID;
    private String date;
    private String salesInquiryID;
    
    /** Creates a new instance of DisplayManagedBean */
    public CustomerDisplayManagedBean() {
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getAge() {
        return age;
    }

    public void setAge(String age) {
        this.age = age;
    }

    public String getEmailAddress() {
        return emailAddress;
    }

    public void setEmailAddress(String emailAddress) {
        this.emailAddress = emailAddress;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    public String getJobPosition() {
        return jobPosition;
    }

    public void setJobPosition(String jobPosition) {
        this.jobPosition = jobPosition;
    }

    public String getmNumber() {
        return mNumber;
    }

    public void setmNumber(String mNumber) {
        this.mNumber = mNumber;
    }

    public String getMaritalStatus() {
        return maritalStatus;
    }

    public void setMaritalStatus(String maritalStatus) {
        this.maritalStatus = maritalStatus;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getpNumber() {
        return pNumber;
    }

    public void setpNumber(String pNumber) {
        this.pNumber = pNumber;
    }
    
    public void doDisplay(PhaseEvent event) {
        try {
            if (name == null) {
                name = (String) FacesContext.getCurrentInstance().getExternalContext().getFlash().get("name");
            }
            if (address == null) {
                address = (String) FacesContext.getCurrentInstance().getExternalContext().getFlash().get("address");
            } 
            if (mNumber == null) {
                mNumber = (String) FacesContext.getCurrentInstance().getExternalContext().getFlash().get("mNumber");
            } 
            if (pNumber == null) {
                pNumber = (String) FacesContext.getCurrentInstance().getExternalContext().getFlash().get("pNumber");
            } 
            if (age == null) {
                age = (String) FacesContext.getCurrentInstance().getExternalContext().getFlash().get("age");
            }
            if (emailAddress == null) {
                emailAddress = (String) FacesContext.getCurrentInstance().getExternalContext().getFlash().get("emailAddress");
            }
            if (jobPosition == null) {
                jobPosition = (String) FacesContext.getCurrentInstance().getExternalContext().getFlash().get("jobPosition");
            }
            if (maritalStatus == null) {
                maritalStatus = (String) FacesContext.getCurrentInstance().getExternalContext().getFlash().get("maritalStatus");
            }
            if (gender == null) {
                gender = (String) FacesContext.getCurrentInstance().getExternalContext().getFlash().get("gender");
            }
            if(date == null){
                 date =(String) FacesContext.getCurrentInstance().getExternalContext().getFlash().get("date");
            }
        /*    if(customerID == null){
                customerID=(String) FacesContext.getCurrentInstance().getExternalContext().getFlash().get("customerID");
            }
            if(salesInquiryID == null){
                salesInquiryID=(String) FacesContext.getCurrentInstance().getExternalContext().getFlash().get("salesInquiryID");
            }*/
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
    
    public void doDisplayForProducts(PhaseEvent event){
    
        System.out.println(":::WEB::: Do Display for Products");
            if(date == null){
                 date =(String) FacesContext.getCurrentInstance().getExternalContext().getFlash().get("date");
            }
            if(customerID == null){
                customerID=(String) FacesContext.getCurrentInstance().getExternalContext().getFlash().get("customerID");
            }
            if(salesInquiryID == null){
                salesInquiryID=(String) FacesContext.getCurrentInstance().getExternalContext().getFlash().get("salesInquiryID");
            }
            System.out.println("DISPLAYED");
        
    }

    public String getDate() {
        return date;
    }

    public void setDate(String date) {
        this.date = date;
    }

    public String getCustomerID() {
        return customerID;
    }

    public void setCustomerID(String customerID) {
        this.customerID = customerID;
    }

    public String getSalesInquiryID() {
        return salesInquiryID;
    }

    public void setSalesInquiryID(String salesInquiryID) {
        this.salesInquiryID = salesInquiryID;
    }
}